package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.saas.domain.dao.DingBundleDao;
import com.xbongbong.saas.domain.entity.DingBundleEntity;
import com.xbongbong.saas.model.DingBundleModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author chenshan
 * @version v1.0
 * @since 2019-08-16 10:50
 */
@Service("dingBundleModel")
public class DingBundleModelImpl implements DingBundleModel {
    @Resource
    private DingBundleDao dingBundleDao;

    @Override
    public Integer insert(DingBundleEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        return dingBundleDao.insert(entity);
    }

    @Override
    public void insertBatch(List<DingBundleEntity> DingBundleRankList) {
        //dingBundleDao.insertBatch(DingBundleRankList);
    }

    @Override
    public Integer save(DingBundleEntity entity) {
        if ( entity.getId() == null || entity.getId().equals(0L) ) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public Integer update(DingBundleEntity entity) {
        return dingBundleDao.update(entity);
    }

    @Override
    public DingBundleEntity getEntity(Long id, String corpid) {
        return dingBundleDao.getByKey(id, corpid);
    }

    @Override
    public Integer deleteByIds(List<Long> ids, String corpid) {
        return null;//dingBundleDao.deleteByIds(ids, corpid);
    }

    @Override
    public List findEntitys(Map<String, Object> param) {
        return dingBundleDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return dingBundleDao.getEntitysCount(param);
    }
    
    /**
     * Description: 查询符合条件的数据（无子表单数据）
     *
     * @param param
     * @return java.util.List<T>
     * @throws
     * @author 魏荣杰
     * @date 2020/10/13 16:07
     * @since
     */
    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }
    
    @Override
    public DingBundleEntity getByOpenConversationId(String corpid,String openConversationId, Integer del) {
        return dingBundleDao.getByOpenConversationId(corpid,openConversationId,null);
    }
    @Override
    public DingBundleEntity getByOpenConversationId(String corpid, String openConversationId) {
        return dingBundleDao.getByOpenConversationId(corpid,openConversationId,0);
    }

    @Override
    public Integer dataConsistencyUpdateUser(String corpid, String ownerId, String name, String avatar) {
        return dingBundleDao.dataConsistencyUpdateUser(corpid, ownerId, name, avatar);
    }

    @Override
    public DingBundleEntity getByType(String corpid, String openConversationId, Integer type) {
        return dingBundleDao.getByType(corpid, openConversationId, type, 0);
    }

    @Override
    public DingBundleEntity getByType(String corpid, String openConversationId, Integer type, Integer del) {
        return dingBundleDao.getByType(corpid, openConversationId, type, del);
    }
}